<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->bigInteger('user_id')->index()->default(0)->comment('用户ID');
            $table->bigInteger('goodsid')->index()->default(0)->comment('商品ID');
            $table->string('machines_imel',150)->default('')->comment('设备号IMEL');
            $table->string('ordersn',150)->default('')->comment('订单号');
			$table->string('machines_name',100)->default('')->comment('设备名称');
			$table->bigInteger('freightway_id')->index()->default(0)->comment('货道ID');
			$table->decimal('goods_total_price')->default(10,2)->comment('商品单价');
			$table->decimal('order_total_price')->default(10,2)->comment('订单总额');
			$table->tinyInteger('payment')->default(0)->comment('支付方式1微信,2支付宝');
			$table->tinyInteger('order_status')->default(0)->comment('订单状态0待支付,1已支付待出货,2已支付已出货,3已超时,4设备故障超时');
			$table->tinyInteger('refund_status')->default(0)->comment('退款状态0未退款1等待退款,2退款成功');
			$table->timestamp('payment_time')->comment('支付时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('orders');
    }
}
